package com.qianchang.microfinance.view.credit.data;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.dm.library.adapter.BaseViewPagerAdapter;
import com.dm.library.adapter.FragmentPageInfo;
import com.qianchang.microfinance.R;
import com.qianchang.microfinance.global.ConstantAppInfo;
import com.qianchang.microfinance.view.base.BaseActivity;
import com.qianchang.microfinance.view.mine.loan.MyLoanJinbaoFragment;
import com.qianchang.microfinance.view.mine.loan.MyLoanMortgageFragment;
import com.qianchang.microfinance.view.mine.loan.MyLoanOwnerFragment;
import com.qianchang.microfinance.view.mine.loan.MyLoanStudentFragment;

import butterknife.BindView;
import butterknife.ButterKnife;

public class RechargeCertificationActivity extends BaseActivity {
    public static final String URL_TYPE = "url_type";
    @BindView(R.id.tab_loan_type)
    TabLayout tabLoanType;
    @BindView(R.id.viewpager)
    ViewPager viewPager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recharge_certification);
        ButterKnife.bind(this);
        initData();
    }

    @Override
    protected void initData() {
        super.initData();
        initViewPager();
    }
    private void initViewPager() {
        BaseViewPagerAdapter adapter = new BaseViewPagerAdapter(this, getSupportFragmentManager(), getPagerInfo());
        viewPager.setAdapter(adapter);
        tabLoanType.setupWithViewPager(viewPager);
    }

    //    CASH("0", "现金贷"),COST("1", "消费贷"),DIYA("2", "抵押贷"),HOUSE_RENT("3", "租房分期"),CAMPUS("4", "学生贷"),OWNER("5", "业主贷");
    private FragmentPageInfo[] getPagerInfo() {
        if (!ConstantAppInfo.IS_ONLY_CASH) {
            //修改不同的status
            tabLoanType.setVisibility(View.VISIBLE);
            return new FragmentPageInfo[]{
                    new FragmentPageInfo(getString(R.string.Label_jinbao_loan), RechargeListFragment.class, setBundleData(0, "cash")),
//                    new FragmentPageInfo(getString(R.string.Label_student_loan), MyLoanStudentFragment.class, setBundleData(4, "campus")),
//                    new FragmentPageInfo(getString(R.string.Label_owner_loan), MyLoanOwnerFragment.class, setBundleData(5, "owner")),
//                    new FragmentPageInfo(getString(R.string.Label_mortgage_loan), MyLoanMortgageFragment.class, setBundleData(2, "diya"))
            };
        } else {
            tabLoanType.setVisibility(View.GONE);
            return new FragmentPageInfo[]{new FragmentPageInfo(getString(R.string.Label_jinbao_loan), RechargeListFragment.class, setBundleData(0, "cash"))};
        }
    }

    public Bundle setBundleData(int productType, String urlType) {
        Bundle bundle = new Bundle();
        bundle.putInt(ConstantAppInfo.PROJECT_TYPE, productType);
        bundle.putString(URL_TYPE, urlType);
        return bundle;
    }
}
